import numpy as np
import pyaudio
import threading
import av
import numpy

if __name__ == '__main__':
    WIDTH = 2
    CHANNELS = 1
    RATE = 44000
    stream_input = pyaudio.PyAudio().open(
        format=pyaudio.PyAudio().get_format_from_width(WIDTH),
        channels=CHANNELS,
        rate=RATE,
        output=True,
    )
    stream_output = pyaudio.PyAudio().open(
        format=pyaudio.PyAudio().get_format_from_width(WIDTH),
        channels=CHANNELS,
        rate=RATE,
        input=True,
    )
    while True:
        try:
            nums = stream_output.get_read_available()
            chunk = stream_output.read(nums)
            stream_input.write(chunk)
        except KeyboardInterrupt:
            break
    stream_input.close()
    stream_output.close()
